﻿using Application.Users.Queries.GetUser;
using FluentValidation;

namespace Application.Validators
{
    public class GetUserFilterValidator : AbstractValidator<GetUserFilter>
    {
        public GetUserFilterValidator()
        {
            RuleFor(x => x.UserNames).Custom((dto,context) =>
            {

            });
            // 分页校验
            RuleFor(x => x.PageNo)
                .GreaterThanOrEqualTo(1).WithMessage("页码必须大于等于 1");
            
            RuleFor(x => x.PageSize)
                .GreaterThanOrEqualTo(1).WithMessage("每页大小必须大于等于 1")
                .LessThanOrEqualTo(100).WithMessage("每页大小不能超过 100");

            // 筛选项数量限制（支持 null）
            RuleFor(x => x.Ids)
                .Must(list => list == null || list.Count <= 100).WithMessage("ID 列表最多包含 100 个项");

            RuleFor(x => x.UserNames)
                .Must(list => list == null || list.Count <= 100).WithMessage("用户名列表最多包含 100 个项");

            RuleFor(x => x.Colleges)
                .Must(list => list == null || list.Count <= 100).WithMessage("学院列表最多包含 10 个项");

            RuleFor(x => x.Majors)
                .Must(list => list == null || list.Count <= 100).WithMessage("专业列表最多包含 10 个项");
            
            RuleFor(x => x.PhoneNumbers)
                .Must(list => list == null || list.Count <= 100).WithMessage("手机号列表最多包含 100 个项");
        }
    }
}
